package com.test.prolenders.bean_prolenders.userinfo_prolenders;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.test.prolenders.R;
import com.test.prolenders.base_prolenders.BaseApplication_prolenders;

import org.json.JSONObject;

public class RpInfo_prolenders {

    private static class Inner {
        private static RpInfo_prolenders instance = new RpInfo_prolenders();
    }

    private RpInfo_prolenders(){}

    public static RpInfo_prolenders getInstance(){
        return Inner.instance;
    }

    public static void parse(JSONObject objJson){
        Inner.instance = new Gson().fromJson(objJson.toString(), RpInfo_prolenders.class);
    }

    private String currency;
    private String days;
    private String repayProFee;
    private String amount;
    private String serviceFee;
    private String serviceVatFee;
    private String overdueDay;
    private String repayAmount;
    private String repayDate;
    private String interest;
    private String overdueAmount;

    public String getCurrency() {
        if (TextUtils.isEmpty(currency)) return "";
        return currency;
    }

    public String getDays() {
        if (TextUtils.isEmpty(days)) return "";
        return days;
    }

    public String getRepayProFee() {
        if (TextUtils.isEmpty(repayProFee)) return "";
        return repayProFee;
    }

    public String getAmount() {
        if (TextUtils.isEmpty(amount)) return "";
        return amount;
    }

    public String getServiceFee() {
        if (TextUtils.isEmpty(serviceFee)) return "";
        return serviceFee;
    }

    public String getServiceVatFee() {
        if (TextUtils.isEmpty(serviceVatFee)) return "";
        return serviceVatFee;
    }

    public String getOverdueDay() {
        if (TextUtils.isEmpty(overdueDay)) return "";

        try {
            int dayInt = Integer.parseInt(overdueDay);
            if (dayInt <= 1) return BaseApplication_prolenders.getInstant().getString(R.string.day_prolenders,dayInt);
            else return BaseApplication_prolenders.getInstant().getString(R.string.days_prolenders,dayInt);

        }catch (NumberFormatException e){
            e.printStackTrace();
            return BaseApplication_prolenders.getInstant().getString(R.string.days_prolenders,0);
        }
    }

    public String getRepayAmount() {
        if (TextUtils.isEmpty(repayAmount)) return "";
        return repayAmount;
    }

    public String getRepayDate() {
        if (TextUtils.isEmpty(repayDate)) return "";
        return repayDate;
    }

    public String getInterest() {
        if (TextUtils.isEmpty(interest)) return "";
        return interest;
    }

    public String getOverdueAmount() {
        if (TextUtils.isEmpty(overdueAmount)) return "";
        return overdueAmount;
    }

    public boolean isOvdu(){
        try {
            return Integer.parseInt(overdueDay)>0;
        }catch (NumberFormatException e){
            e.printStackTrace();
            return false;
        }
    }

}
